home *** CD-ROM | disk | FTP | other *** search
/ Freelog 121 / FreelogMagazineJuilletAout2014-No121.iso / Outils / Adobe-Air / adobe-air_13.exe / [0] / setup.swf / scripts / mx / accessibility / ButtonAccImpl.as < prev    next >
Text File  |  2014-03-27  |  3KB  |  103 lines

  1. package mx.accessibility
  2. {
  3.    import flash.accessibility.Accessibility;
  4.    import flash.events.Event;
  5.    import flash.events.KeyboardEvent;
  6.    import flash.ui.Keyboard;
  7.    import mx.controls.Button;
  8.    import mx.core.UIComponent;
  9.    import mx.core.mx_internal;
  10.    
  11.    use namespace mx_internal;
  12.    
  13.    public class ButtonAccImpl extends AccImpl
  14.    {
  15.       
  16.       private static const EVENT_OBJECT_STATECHANGE:uint = 32778;
  17.       
  18.       private static const STATE_SYSTEM_PRESSED:uint = 8;
  19.       
  20.       private static var accessibilityHooked:Boolean = hookAccessibility();
  21.       
  22.       private static const EVENT_OBJECT_NAMECHANGE:uint = 32780;
  23.       
  24.       mx_internal static const VERSION:String = "3.0.0.0";
  25.        
  26.       
  27.       public function ButtonAccImpl(param1:UIComponent)
  28.       {
  29.          super(param1);
  30.          role = 43;
  31.       }
  32.       
  33.       mx_internal static function createAccessibilityImplementation(param1:UIComponent) : void
  34.       {
  35.          param1.accessibilityImplementation = new ButtonAccImpl(param1);
  36.       }
  37.       
  38.       private static function hookAccessibility() : Boolean
  39.       {
  40.          Button.createAccessibilityImplementation = mx_internal::createAccessibilityImplementation;
  41.          return true;
  42.       }
  43.       
  44.       public static function enableAccessibility() : void
  45.       {
  46.       }
  47.       
  48.       override protected function eventHandler(param1:Event) : void
  49.       {
  50.          switch(param1.type)
  51.          {
  52.             case "click":
  53.                Accessibility.sendEvent(master,0,EVENT_OBJECT_STATECHANGE);
  54.                Accessibility.updateProperties();
  55.                break;
  56.             case "labelChanged":
  57.                Accessibility.sendEvent(master,0,EVENT_OBJECT_NAMECHANGE);
  58.                Accessibility.updateProperties();
  59.          }
  60.       }
  61.       
  62.       override protected function getName(param1:uint) : String
  63.       {
  64.          var _loc2_:String = Button(master).label;
  65.          return _loc2_ != null && _loc2_ != "" ? _loc2_ : "";
  66.       }
  67.       
  68.       override public function get_accState(param1:uint) : uint
  69.       {
  70.          var _loc2_:uint = getState(param1);
  71.          if(Button(master).selected)
  72.          {
  73.             _loc2_ |= STATE_SYSTEM_PRESSED;
  74.          }
  75.          return _loc2_;
  76.       }
  77.       
  78.       override public function accDoDefaultAction(param1:uint) : void
  79.       {
  80.          var _loc2_:KeyboardEvent = null;
  81.          if(master.enabled)
  82.          {
  83.             _loc2_ = new KeyboardEvent(KeyboardEvent.KEY_DOWN);
  84.             _loc2_.keyCode = Keyboard.SPACE;
  85.             master.dispatchEvent(_loc2_);
  86.             _loc2_ = new KeyboardEvent(KeyboardEvent.KEY_UP);
  87.             _loc2_.keyCode = Keyboard.SPACE;
  88.             master.dispatchEvent(_loc2_);
  89.          }
  90.       }
  91.       
  92.       override protected function get eventsToHandle() : Array
  93.       {
  94.          return super.eventsToHandle.concat(["click","labelChanged"]);
  95.       }
  96.       
  97.       override public function get_accDefaultAction(param1:uint) : String
  98.       {
  99.          return "Press";
  100.       }
  101.    }
  102. }
  103.